<?php 
include('../../Connections/KRAPPERCON.php');
$oper = $_POST['oper'];
$codart = $_POST['codart'];
$nom = $_POST['nomart'];
$des = $_POST['txtdesc'];
$marca = $_POST['cbxmarca'];
$familia = $_POST['cbxfamilia'];
$color = $_POST['cbxcolor'];
$clase = $_POST['cbxclase'];
$precio = $_POST['txtprecio'];
$costo = $_POST['txtcosto'];
$sts = $_POST['cbxest'];
$prov = $_POST['cbxproveedor'];
$new = $_POST['txtcodnew'];
$items = $_POST['items'];
$dsctoIn = getVal('dsctoIn');
$dsctoOut = getVal('dsctoOut');
/*
oper : oper,
codart : GEBI('t_cod').value ,
nomart : GEBI('t_nomart').value ,
txtdesc : GEBI('t_descripcion').value ,
cbxmarca : GEBI('cb_marca').value ,
cbxfamilia : GEBI('cb_familia').value ,
cbxcolor : GEBI('cb_color').value ,
cbxclase : GEBI('cb_clase').value ,
posicion :  GEBI('t_posicion').value,
txtprecio : GEBI('t_precio').value ,
txtcosto : GEBI('t_costo').value ,
cbxest : GEBI('cb_est').value,
cbxproveedor : GEBI('cb_proveedor').value ,
txtcodnew : GEBI('t_codnew').value,
items : itms
*/

if ($oper == 'upd'){
$sql = "call sp_saveMARA('".$codart."','".$nom."','".$des."','".$marca."','".
$familia."','".$color."','".$clase."','".$precio."','".$costo."','".
$user_now."','".$prov."',".$sts.",'".$new."','".$dsctoIn."','".$dsctoOut."','".$items."');";
doEcho($sql);

$res = $mysqli->query($sql) or die($mysqli->error.__LINE__);;
	if ($res){
		if ($row = $res->fetch_assoc()){
			if ($row['newnro'] == $codart){
				echo "<script>showOk('Se ".$row['msg_ok']." correctamente el Articulo ".$codart."');</script>";
			}
			else {
				echo "<script>showError('".$row['msg_err']."');</script>";
			}
		}
		$res->close();
		$mysqli->check_result();		
	}
}

?>
<?php 


/*








 $tipo = $_POST["tipo"];

if ($tipo ==""){


$query = "
call sp_grabaart('".$_POST['codart']."','".$_POST['nomart']."','".$_POST['txtdesc']."','".$_POST['cbxmarca']."',
'".$_POST['cbxfamilia']."','".$_POST['cbxcolor']."','".$_POST['cbxclase']."','".$_POST['posicion']."',
".$_POST['txtprecio'].",".$_POST['txtcosto'].",
'".$_POST['userid']."','".$_POST['cbxproveedor']."',".$_POST['cbxest'].",'".$_POST['txtcodnew']."');
  

";
echo $query;
$res = $mysqli->query($query);
if ($res) {
		while($row = $res->fetch_assoc()) {
		echo "";
		}
$res->close();
$mysqli->next_result();
}



}else{
$query = "
call sp_actualizaart('".$_POST['codart']."','".$_POST['nomart']."','".$_POST['txtdesc']."','".$_POST['cbxmarca']."',
'".$_POST['cbxfamilia']."','".$_POST['cbxcolor']."','".$_POST['cbxclase']."','".$_POST['posicion']."',
".$_POST['txtprecio'].",".$_POST['txtcosto'].",
'".$_POST['cbxproveedor']."',".$_POST['cbxest'].",'".$_POST['txtcodnew']."');";
//$res = mysql_query($query);
$res = $mysqli->query($query);
if ($res) {
		while($row = $res->fetch_assoc()) {
echo " ";
		}
$res->close();
$mysqli->next_result();
}

}



for ($i=0;$i<$cant; $i ++ ){

$query="
call Sp_grabArtAlmacen  ('".$pieces[$i]."','".$pieces2[$i]."','".$_POST['codart']."','".$_POST['userid']."');

";
//$res = mysql_query($query);
echo $query;
$res = $mysqli->query($query);
if ($res) {
		while($row = $res->fetch_assoc()) {
	echo " ";
		}
$res->close();
$mysqli->next_result();
}


} 




 echo "<script>loadPage('Mantenimientos/MantArt.php'); </script>";

echo "<script>showOk('OPERACION EXISTOSA!!!'); </script>";



*/
?>


